#include "../EventLoop.h"
#include "../TcpServer.h"
#include "../TcpConnection.h"
#include <stdio.h>
#include <unistd.h>
#include "../util.h"

void onConnection(const TcpConnectionPtr& conn) {
    // std::cout << "TcpServer::onConnection" << std::endl;
}

void onMessage(const TcpConnectionPtr& conn, Buffer* buf) {
    // printf("TID: %d TcpConnection::onMessage\n", getTid());
    conn->send(buf);
}

int main () {
    int numThreads = 4;

    EventLoop mainLoop;
    
    TcpServer server(&mainLoop, 12345);
    server.setThreadNum(numThreads);
    server.setConnectionCallback(onConnection);
    server.setMessageCallback(onMessage);
    server.start();

    mainLoop.loop();

    return 0;
}

// g++ -std=c++17 main.cpp ../*.cpp  -lpthread -o server

